package com.lowrisk.springcloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Author jiadianduo
 * @Description:
 * @Date:Created in 2019/3/24 10:01
 */
@RestController
@SpringBootApplication
@EnableEurekaClient
public class Application {

    @RequestMapping(value = "/hello")
    public String home(){
        return "hello world";
    }

    @RequestMapping("info")
    public String info(){
        return "microservice-eureka-user";
    }

    /**
     * RestTemplate 同rest方式来实现服务之前的调用
     * @return
     */
    @Bean
    @LoadBalanced // Ribben 实现客户端负载均衡，使用默认的算法
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }


    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);

    }
}
